#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <sys/types.h>
#include <unistd.h>

int a =1;
int b =2;
int c;

int makeChild();
void childMain();

int main(int argc,char *argv[])
{
	pid_t p = makeChild();
	printf("end of main()%10d\n",p);
	return 0;	
}

int makeChild()
{
	pid_t pid = fork();
	if(pid < 0)
	{
		printf("%s %d fork() error:%s\n",__FILE__,__LINE__,strerror(errno));
		return -1;
	}
	else
	{
		if(pid >0)
		{
			close(0);
			return pid;
		}
	}
	setpgrp();
	childMain();
	return 0;
}

void childMain()
{

	asm volatile
    	(
     	"movl a,%eax\n\t"
     	"addl b,%eax\n\t"
     	"movl %eax,c\n\t"
    	);
    printf("c = [%d]\n",c);
}
